<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:WinRTXamlToolkit.Controls"
    xmlns:converters="using:WinRTXamlToolkit.Converters"
    xmlns:Extensions="using:WinRTXamlToolkit.Controls.Extensions">
    <!-- UnlabeledAppBarButtonStyle -->
    <Style
        x:Key="UnlabeledAppBarButtonStyle"
        TargetType="Button">
        <Setter
            Property="Foreground"
            Value="{StaticResource AppBarItemForegroundThemeBrush}" />
        <Setter
            Property="VerticalAlignment"
            Value="Stretch" />
        <Setter
            Property="FontFamily"
            Value="Segoe UI Symbol" />
        <Setter
            Property="FontWeight"
            Value="Normal" />
        <Setter
            Property="FontSize"
            Value="20" />
        <Setter
            Property="Padding"
            Value="10" />
        <Setter
            Property="AutomationProperties.ItemType"
            Value="App Bar Button" />
        <Setter
            Property="Template">
            <Setter.Value>
                <ControlTemplate
                    TargetType="Button">
                    <Grid
                        x:Name="RootGrid"
                        Background="Transparent">
                        <Grid
                            Margin="{TemplateBinding Padding}">
                            <Grid
                                Width="40"
                                Height="40"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Top"
                                Margin="0,12,0,11">
                                <TextBlock
                                    x:Name="BackgroundGlyph"
                                    Text="&#xE0A8;"
                                    FontFamily="Segoe UI Symbol"
                                    FontSize="53.333"
                                    Margin="-4,-19,0,0"
                                    Foreground="{StaticResource AppBarItemBackgroundThemeBrush}" />
                                <TextBlock
                                    x:Name="OutlineGlyph"
                                    Text="&#xE0A7;"
                                    FontFamily="Segoe UI Symbol"
                                    FontSize="53.333"
                                    Margin="-4,-19,0,0" />
                                <ContentPresenter
                                    x:Name="Content"
                                    HorizontalAlignment="Center"
                                    Margin="-1,-1,0,0"
                                    VerticalAlignment="Center" />
                            </Grid>
                        </Grid>
                        <Rectangle
                            x:Name="FocusVisualWhite"
                            IsHitTestVisible="False"
                            Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
                            StrokeEndLineCap="Square"
                            StrokeDashArray="1,1"
                            Opacity="0"
                            StrokeDashOffset="1.5" />
                        <Rectangle
                            x:Name="FocusVisualBlack"
                            IsHitTestVisible="False"
                            Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
                            StrokeEndLineCap="Square"
                            StrokeDashArray="1,1"
                            Opacity="0"
                            StrokeDashOffset="0.5" />

                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup
                                x:Name="ApplicationViewStates">
                                <VisualState
                                    x:Name="FullScreenLandscape" />
                                <VisualState
                                    x:Name="Filled" />
                                <VisualState
                                    x:Name="FullScreenPortrait">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="RootGrid"
                                            Storyboard.TargetProperty="Width">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="60" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState
                                    x:Name="Snapped">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="RootGrid"
                                            Storyboard.TargetProperty="Width">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="60" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup
                                x:Name="CommonStates">
                                <VisualState
                                    x:Name="Normal" />
                                <VisualState
                                    x:Name="PointerOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="BackgroundGlyph"
                                            Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="{StaticResource AppBarItemPointerOverBackgroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="Content"
                                            Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="{StaticResource AppBarItemPointerOverForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState
                                    x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="OutlineGlyph"
                                            Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="{StaticResource AppBarItemForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="BackgroundGlyph"
                                            Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="{StaticResource AppBarItemForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="Content"
                                            Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="{StaticResource AppBarItemPressedForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState
                                    x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="OutlineGlyph"
                                            Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="{StaticResource AppBarItemDisabledForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="Content"
                                            Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="{StaticResource AppBarItemDisabledForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup
                                x:Name="FocusStates">
                                <VisualState
                                    x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="FocusVisualWhite"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0" />
                                        <DoubleAnimation
                                            Storyboard.TargetName="FocusVisualBlack"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState
                                    x:Name="Unfocused" />
                                <VisualState
                                    x:Name="PointerFocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- UnlabeledPreviousAppBarButtonStyle -->
    <Style
        x:Key="UnlabeledPreviousAppBarButtonStyle"
        TargetType="Button"
        BasedOn="{StaticResource UnlabeledAppBarButtonStyle}">
        <Setter
            Property="AutomationProperties.AutomationId"
            Value="PreviousAppBarButton" />
        <Setter
            Property="AutomationProperties.Name"
            Value="Previous" />
        <Setter
            Property="Content"
            Value="&#xE112;" />
    </Style>

    <!-- UnlabeledNextAppBarButtonStyle -->
    <Style
        x:Key="UnlabeledNextAppBarButtonStyle"
        TargetType="Button"
        BasedOn="{StaticResource UnlabeledAppBarButtonStyle}">
        <Setter
            Property="AutomationProperties.AutomationId"
            Value="NextAppBarButton" />
        <Setter
            Property="AutomationProperties.Name"
            Value="Next" />
        <Setter
            Property="Content"
            Value="&#xE111;" />
    </Style>

    <!-- UnlabeledNoAppBarButtonStyle -->
    <Style
        x:Key="UnlabeledNoAppBarButtonStyle"
        TargetType="Button"
        BasedOn="{StaticResource UnlabeledAppBarButtonStyle}">
        <Setter
            Property="AutomationProperties.AutomationId"
            Value="NoAppBarButton" />
        <Setter
            Property="AutomationProperties.Name"
            Value="No" />
        <Setter
            Property="Content"
            Value="&#xE10A;" />
    </Style>

    <!-- UnlabeledRefreshAppBarButtonStyle -->
    <Style
        x:Key="UnlabeledRefreshAppBarButtonStyle"
        TargetType="Button"
        BasedOn="{StaticResource UnlabeledAppBarButtonStyle}">
        <Setter
            Property="AutomationProperties.AutomationId"
            Value="RefreshAppBarButton" />
        <Setter
            Property="AutomationProperties.Name"
            Value="Refresh" />
        <Setter
            Property="Content"
            Value="&#xE117;" />
    </Style>

    <!-- WebBrowser default style -->
    <Style
        TargetType="controls:WebBrowser">
        <Setter
            Property="Template">
            <Setter.Value>
                <ControlTemplate
                    TargetType="controls:WebBrowser">
                    <Grid
                        x:Name="PART_LayoutRoot">
                        <Grid.Resources>
                            <converters:BooleanToVisibilityConverter
                                x:Key="BooleanToVisibilityConverter" />
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup
                                x:Name="LoadingStates">
                                <VisualState
                                    x:Name="LoadingState">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_ProgressIndicator"
                                            Storyboard.TargetProperty="IsIndeterminate">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="True" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_StopButton"
                                            Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="Visible" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_RefreshButton"
                                            Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_GoButton"
                                            Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState
                                    x:Name="LoadedState" />
                            </VisualStateGroup>
                            <VisualStateGroup
                                x:Name="AddressBarStates">
                                <VisualState
                                    x:Name="AddressBarFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_AddressBar"
                                            Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="{StaticResource TextBoxForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_AddressBar"
                                            Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="{StaticResource TextBoxBackgroundThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <!--<DoubleAnimation
                                            Duration="0"
                                            To="0"
                                            Storyboard.TargetName="PART_BackButton"
                                            Storyboard.TargetProperty="Opacity" />-->
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_BackButton"
                                            Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_FavIconImage"
                                            Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="FavIconBackground"
                                            Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_RefreshButton"
                                            Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_ForwardButton"
                                            Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_GoButton"
                                            Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="Visible" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState
                                    x:Name="AddressBarUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="PART_GoButton"
                                            Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0"
                                                Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid.Background>
                            <WebViewBrush
                                x:Name="PART_WebViewBrush"
                                SourceName="PART_WebView" />
                        </Grid.Background>
                        <WebView
                            x:Name="PART_WebView" />
                        <controls:CustomAppBar
                            x:Name="PART_TitleAppBar"
                            IsLightDismissEnabled="True"
                            VerticalAlignment="Top"
                            Extensions:FrameworkElementExtensions.ClipToBounds="True">
                            <!--Visibility="{Binding IsOpen, RelativeSource={RelativeSource Self}, Converter={StaticResource BooleanToVisibilityConverter}}">-->
                            <TextBlock
                                x:Name="PART_TitleBar"
                                FontSize="24"
                                Margin="6" />
                        </controls:CustomAppBar>

                        <!-- TODO: What's up with Grid.Row="2" here in a single row grid? -->
                        <controls:CustomAppBar
                            x:Name="PART_AddressAppBar"
                            Grid.Row="2"
                            IsLightDismissEnabled="True"
                            VerticalAlignment="Bottom"
                            IsOpen="True"
                            Extensions:FrameworkElementExtensions.ClipToBounds="True">
                            <!--Visibility="{Binding IsOpen, RelativeSource={RelativeSource Self}, Converter={StaticResource BooleanToVisibilityConverter}}">-->
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition
                                        Width="60" />
                                    <ColumnDefinition
                                        Width="41" />
                                    <ColumnDefinition />
                                    <ColumnDefinition
                                        Width="Auto" />
                                    <ColumnDefinition
                                        Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Button
                                    x:Name="PART_BackButton"
                                    Style="{StaticResource UnlabeledPreviousAppBarButtonStyle}"
                                    AutomationProperties.Name="" />
                                <Border
                                    x:Name="FavIconBackground"
                                    Background="{StaticResource ApplicationForegroundThemeBrush}"
                                    VerticalAlignment="Center"
                                    BorderThickness="0"
                                    Width="41"
                                    Height="41"
                                    Grid.Column="1">
                                    <Image
                                        x:Name="PART_FavIconImage"
                                        VerticalAlignment="Center"
                                        HorizontalAlignment="Center"
                                        Margin="4"
                                        Stretch="Uniform" />
                                </Border>
                                <TextBox
                                    x:Name="PART_AddressBar"
                                    VerticalAlignment="Center"
                                    Background="{StaticResource AppBarBackgroundThemeBrush}"
                                    Foreground="{StaticResource AppBarItemForegroundThemeBrush}"
                                    FontSize="22"
                                    MinHeight="32"
                                    Margin="0,5"
                                    Grid.Column="2" />
                                <ProgressBar
                                    x:Name="PART_ProgressIndicator"
                                    Grid.Column="2"
                                    VerticalAlignment="Top" />
                                <Button
                                    x:Name="PART_GoButton"
                                    Grid.Column="3"
                                    Visibility="Collapsed"
                                    Style="{StaticResource UnlabeledNextAppBarButtonStyle}"
                                    AutomationProperties.Name="" />
                                <Button
                                    x:Name="PART_StopButton"
                                    Grid.Column="3"
                                    Style="{StaticResource UnlabeledNoAppBarButtonStyle}"
                                    Visibility="Collapsed"
                                    AutomationProperties.Name="" />
                                <Button
                                    x:Name="PART_RefreshButton"
                                    Grid.Column="3"
                                    Style="{StaticResource UnlabeledRefreshAppBarButtonStyle}"
                                    AutomationProperties.Name="" />
                                <Button
                                    x:Name="PART_ForwardButton"
                                    Grid.Column="4"
                                    Style="{StaticResource UnlabeledNextAppBarButtonStyle}"
                                    AutomationProperties.Name="" />
                            </Grid>
                        </controls:CustomAppBar>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
